package com.lcq.study.test.demo.service;

import com.lcq.study.test.demo.entity.People;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @ClassName HelloService
 * @Description
 * @Author lichuanqi
 * @Date 2022/5/12 11:59
 * @Version 1.0
 **/
@Service
@Slf4j
public class CacheService {

    public String getName(String id){
        return id+":name";
    }
    @Cacheable(value = "createCache")
    public String createCache() {
        log.info("createCache!!!");
        return UUID.randomUUID().toString();
    }

    @Cacheable(value = "createCache1")
    public String createCache1() {
        log.info("createCache!!!");
        return UUID.randomUUID().toString();
    }

    @CacheEvict(value = "createCache")
    public void deleteCache() {
        log.info("deleteCache!!!");
    }

    @Cacheable(value = "people")
    public People people() {
        People people = new People();
        people.setId(UUID.randomUUID().toString());
        people.setAge(20);
        people.setName("wuma");
        log.info("people!!!");
        return people;
    }
    @CacheEvict(value = "people")
    public void deletePeople() {
        log.info("deletePeople!!!");
    }
}
